/*
 * Copyright 2003-2007 Program of Computer Graphics, Cornell University
 *     580 Rhodes Hall
 *     Cornell University
 *     Ithaca NY 14853
 * Web: http://www.graphics.cornell.edu/
 * 
 * Not for commercial use. Do not redistribute without permission.
 */

// Platform specific definitions. They might need to be cleaned as they clearly show
// their Windows origins.

#ifndef _H_BRITEDEFS
#define _H_BRITEDEFS


#include <math.h>
#include <float.h>
#ifdef _MSC_VER
#include <intrin.h>
#endif

// Variable sized types according to the architecture
#ifdef _WIN32
#include <BaseTsd.h>	// Definition of LONG_PTR in Windows
#else
#include <stdint.h>
#if defined(_LP64) || defined(__LP64__)
 typedef int64_t LONG_PTR; 
#else
 typedef long LONG_PTR;
#endif
#endif

// 64 bit compilation requires different treatment of the data:
// because the pointers grew to 64 bits, things can get missaligned
#if defined(_LP64) || defined(__LP64__) || defined(_WIN64)
# define BRITE_64 1
# if defined(__clang__)
#  define BRITE_UNUSED __attribute__((unused))
# else
#  define BRITE_UNUSED
# endif
#endif


// Compiler intrinsics for debug traps (e.g. x86 "int 3" instruction)
#if defined(_MSC_VER)
	#define BRITE_DEBUGBREAK __debugbreak()
#else
	#define BRITE_DEBUGBREAK __builtin_trap()
#endif


// Defines the return values for fpclass (and fpclass itself!)
 namespace brite {
	 const int GOOD_FLOAT_MASK = 
#ifdef _MSC_VER
	(_FPCLASS_NN | _FPCLASS_PN | _FPCLASS_NZ | _FPCLASS_PZ); //normal, nonzero fp numbers
#else
	(FP_ZERO | FP_NORMAL);
#endif

 }
#ifndef _MSC_VER
#define _fpclass(x) fpclassify(x)
#endif


#endif	// _H_BRITEDEFS
